package com.peng.scalatest

/**
 * 模式匹配
 */
object ScalaTest7_Match {
  def main(args: Array[String]): Unit = {
    val tuple: (Int, Int, String, String, Int, Int, Int, Boolean) = (1, 2, "asd", "heihei", 60, 88, 100, false)
    tuple.productIterator.foreach((x: Any) => {
      x match {
        case 1 => println("is 1")
        case q: Int => println(s"int q is $q")
        case false => println("false")
        case t: String if t.equals("heihei") => println(s"$t heihei equals...")
        case _ => println("other....")
      }
    })

    for (elem <- 1 to 10) elem match {
      case e: Int if e > 5 => println(s"$e>5")
      case _ => println("other")
    }

    val a = 20
    a match {
      case x: Int => println("is int")
      case _ => println("not anything")
    }

  }


}
